<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<script src="/xlive/script/xlv.js"></script>
</head>
<body>
	<div id="catalog_main" xlvobject="xlv.obj.borderLayout"
		xlvmethod="{
			styleFor:function(layout){
				var style={width:'100%',background:'url(/xlive/images/grayTexture.gif) left top repeat'};
				style.borderLeft='1px solid gray';
				style.borderTop='1px solid gray';
				style.borderRight='1px solid white';
				style.borderBottom='1px solid white';
				style.minHeight='480px';
				style.fontFamily='Arial';
				style.fontSize='12px';
				Element.setStyle(layout,style);
			}
		}">
		<style type="text/css">
			#forum_catalog_table #catalog_expand{
				width:32px;height:32px;
				background: url('/xlive/images/forum/downArrow.png') left top no-repeat;
			}
			li.expanded #forum_catalog_table #catalog_expand{
				width:32px;height:32px;
				background: url('/xlive/images/forum/upArrow.png') left top no-repeat;
			}
		</style>
		
		<div xlvobject="xlv.obj.webObject" xlvprop="{name:'forum.catalog',objectURL:'forum.catalog',methodName:'catalog-tree'}"
			 	xlvmethod="{
				 	initial:function(){
				 		var forum_main=xlv.util.findParent(this,{id:'forum_main'});
				 		var forum_key=forum_main.$P.forumKey;
			 			this.$P.webObjectProperties={'catalog-tree':{'forum-key':forum_key}};
			 			this.$self('initial');
			 		}
			 	}"
		>
		</div>
		<div xlvobject="xlv.obj.dmTrigger" xlvprop="{dmName:'forum.catalog',listener:{when:'afterModelChanged',notify:'setChanged',memoType:'create',memoMethods:'update-schema'}}" xlvmethod="{
	  	    	process:function(){
	  	    		var dm=this.getDataModel();
	  	    		var key=dm.getValue('properties.update-schema.schema-key');
	  	    		var node=dm.getNode('properties.catalog-tree.return.sql-statement.return.data.CATALOG_KEY.r[SCHEMA_KEY ='+key+']');
	  	    		if(node != null){
	  	    			xlv.util.setXmlText(xlv.util.selectXmlSingleNode('SCHEMA_TITLE', node),dm.getValue('properties.update-schema.schema-title'));
	  	    			xlv.util.setXmlText(xlv.util.selectXmlSingleNode('SCHEMA_TEXT', node),dm.getValue('properties.update-schema.schema-text'));
	  	    			xlv.util.setXmlText(xlv.util.selectXmlSingleNode('SCHEMA_ICON', node),dm.getValue('properties.update-schema.schema-icon'));
	  	    			dm.select(node);
	  	    		}
	  	    	}
	  	    }"></div>	
		 <div xlvobject="xlv.obj.dmTrigger"
	  	   xlvprop="{dmName:'forum.catalog',listener:{when:'afterModelChanged',notify:'setChanged',memoType:'create',memoMethods:'delete-schema'}}"	
	  	    xlvmethod="{
	  	    	process:function(){
	  	    		var dm=this.getDataModel();
	  	    		var key=dm.getValue('properties.delete-schema.schema-key');
	  	    		var node=dm.getNode('properties.catalog-tree.return.sql-statement.return.data.CATALOG_KEY.r[SCHEMA_KEY ='+key+']');
	  	    		if(node != null){
	  	    			dm.remove(node);
	  	    		}
	  	    	}
	  	    }"
	    ></div>	
		<div xlvobject="xlv.obj.dmTrigger"
	  	   xlvprop="{dmName:'forum.catalog',listener:{when:'afterModelChanged',notify:'setChanged',memoType:'create',memoMethods:'update-catalog'}}"	
	  	    xlvmethod="{
	  	    	process:function(){
	  	    		var dm=this.getDataModel();
	  	    		var key=dm.getValue('properties.update-catalog.catalog-key');
	  	    		var node=dm.getNode('properties.catalog-tree.return.sql-statement.return.data.CATALOG_KEY[@CATALOG_KEY ='+key+']');
	  	    		if(node != null){
	  	    			node.setAttribute('CATALOG_TITLE',dm.getValue('properties.update-catalog.catalog-title'));
	  	    			node.setAttribute('CATALOG_TEXT',dm.getValue('properties.update-catalog.catalog-text'));
	  	    			node.setAttribute('CATALOG_ICON',dm.getValue('properties.update-catalog.catalog-icon'));
	  	    		}
	  	    	}
	  	    }"
	    ></div>	
		<div xlvobject="xlv.obj.dmTrigger"
	  	   xlvprop="{dmName:'forum.catalog',listener:{when:'afterModelChanged',notify:'setChanged',memoType:'create',memoMethods:'delete-catalog'}}"	
	  	    xlvmethod="{
	  	    	process:function(){
	  	    		var dm=this.getDataModel();
	  	    		var key=dm.getValue('properties.delete-catalog.catalog-key');
	  	    		var node=dm.getNode('properties.catalog-tree.return.sql-statement.return.data.CATALOG_KEY[@CATALOG_KEY ='+key+']');
	  	    		if(node != null){
	  	    			dm.remove(node);
	  	    		}
	  	    	}
	  	    }"
	    ></div>	
		<div id="xlvid_north" style="padding:4px 0 0 0">
			<img src='/xlive/images/forum/blue_pin.png'><span  style="font-size:13px;font-weight:bold">catalog</span></img>
		</div>
		<div id="xlvid_center">	
			<div id="new_catalog" xlvobject="xlv.obj.dmProcess" xlvprop="{dmName:'user',title:'new Catalog'}" style="display:none;margin:8px"
			   	 xlvmethod="{
			    	 	process:function(options){
			      	 		var dm_catalog=this.getDataModel('forum.catalog');
			      	 		dm_catalog.setValue('/xlive/images/forum/catalog.png','properties.new-catalog.catalog-icon');
			      	 		dm_catalog.setValue(dm_catalog.getValue('properties.catalog-tree.forum-key'),'properties.new-catalog.forum-key');
			       	 		var user=this.getDataModel('user');
			      	 		dm_catalog.setValue(user.getValue('login.return.data.user-key'),'properties.new-catalog.user-key');
			      	 		dm_catalog.setValue('','properties.new-catalog.catalog-title');
			       	 		dm_catalog.setValue('','properties.new-catalog.catalog-text');
			       	 		this.getDesktop().showPane('/xlive/forum/newCatalog.html',null,null,{invoker:this,align:'left'});
			           },
			           mvc_enableControl:function(dm){
			           		var valid=dm.isPasswordValid() &amp;&amp; dm.isForumAdmin();
			           		this.style.display=((valid)?'':'none');
			           }
			     }"
			><img src="/xlive/images/forum/catalog.png" width="48" height="48"></img>
			</div>
			<div id="forum_catalog" xlvobject="xlv.obj.accordion" style="width:720px"
			     xlvprop="{dmName:'forum.catalog',dmPath:'catalog-tree.return.sql-statement.return.data'}"
			     xlvmethod="{
			     	styleFor:function(li,indexes,leaf){
						li.setAttribute('unselectable','on');
						var style={background:'none',textAlign:'left'};
						if(leaf)style.margin='0 20px 0 20px';
						Element.setStyle(li,style);
					},
			     	mvc_valueToView:function(node,indexes){
			     		var li=xlv.util.findLIAtIndexes(this.$V.rootUL,indexes);
			     		if(li.viewer)li.viewer.mvc_valueToView(node,indexes);
			     	}
			     }"
			     >
			    <ul>
			    	<li>
			    		<div id="catalog_pane" xlvobject="xlv.obj.pane" xlvprop="{glow:{enable:true},border:{enable:true}}" 
			    			 xlvmethod="{
			    			 	styleFor:function(root){
			    			 	 	root.style.background='white';
			    			 	},
			    			 	mvc_valueToView:function(node,indexes){
			    			 		this.$V.catalog_node=node;
			    			 		xlv.util.setElementValue(this.getObjectById('catalog_title'),node.getAttribute('CATALOG_TITLE'));
			    			 		this.getObjectById('catalog_icon').src=node.getAttribute('CATALOG_ICON');
			    			 		this.getObjectById('catalog_text').innerHTML=node.getAttribute('CATALOG_TEXT');
			    			 		var user_name=this.getObjectById('user_name');
			    			 		user_name.setTitle(node.getAttribute('CATALOG_USER_NAME'));
			    			 		user_name.$V.user_key=node.getAttribute('CATALOG_USER_KEY');
			    			 		var value=node.getAttribute('CATALOG_TIME');
			    			 		value=new Date().parseDate(value).formatDate('yyyy/MM/dd HH:mm:ss');
			    			 		xlv.util.setElementValue(this.getObjectById('catalog_time'),value);
			    			 	}
			    			 }"
			    			>
			    			<div style="padding:10px">
			    			<table id="forum_catalog_table" border="0" cellpadding="0" cellspacing="0">
			    				<tr>
			    					<td rowSpan="2"><img width="48" id="catalog_icon" style="margin-right:8px"></img></td>
			    					<td>
			    						<span id="catalog_title" style="text-align:left;vertical-align:top;font-weight:bold;font-size:larger;"></span>
			    					</td>
			    					<td>
			    						<nobr>
			    						<span title="update catalog" id="update_catalog" xlvobject="xlv.obj.dmProcess"  style="display:none"
			    							xlvprop="{dmName:'user',srcImg:'/xlive/images/forum/page_edit.png',title:''}"
			    							xlvmethod="{
			    							  	 	process:function(options){
			    							  	 		var node=this.getPaneById('catalog_pane').$V.catalog_node;
			    							  	 		var dm_catalog=this.getDataModel('forum.catalog');
			    							  	 		dm_catalog.setValue(node.getAttribute('CATALOG_KEY'),'properties.update-catalog.catalog-key');
			    							   	 		dm_catalog.setValue(node.getAttribute('CATALOG_TITLE'),'properties.update-catalog.catalog-title');
			    							   	 		dm_catalog.setValue(node.getAttribute('CATALOG_TEXT'),'properties.update-catalog.catalog-text');
			    							   	 		dm_catalog.setValue(node.getAttribute('CATALOG_ICON'),'properties.update-catalog.catalog-icon');
			    							   	 		this.getDesktop().showPane('/xlive/forum/updateCatalog.html',null,null,{invoker:this,align:'right'});
			    							   	 	},
			    							   	 	mvc_enableControl:function(dm){
			    							   	 		var valid;
			    							   	 		if(vaild=dm.isPasswordValid()){
			    							   	 			if(!(valid=dm.isForumAdmin())){
			    							   	 				var user_key=dm.getValue('login.return.data.user-key');
			    							   	 				var node=this.getPaneById('catalog_pane').$V.catalog_node;
			    							   	 				valid=(user_key==node.getAttribute('CATALOG_USER_KEY'));
			    							   	 			}
			    							   	 		}
			    							   	 		this.style.display=((valid)?'':'none');
			           								}
			    							}"
			    						>
			    						</span>
			    						<span title="delete catalog" xlvobject="xlv.obj.dmProcess" style="display:none"
			    							 xlvprop="{dmName:'user',srcImg:'/xlive/images/forum/page_delete.png',title:''}"
			    							 xlvmethod="{
			    							   	 	process:function(options){
			    							  	 		var node=this.getPaneById('catalog_pane').$V.catalog_node;
			    							   	 		var dm_catalog=this.getDataModel('forum.catalog');
			    							   	 		var catalog_key=node.getAttribute('CATALOG_KEY');
			    							   	 		var catalog_title=node.getAttribute('CATALOG_TITLE');
			    							   	 		if(!confirm('delete this catalog : \n\n'+catalog_title)) return;
			    							   	 		dm_catalog.setValue(catalog_key,'properties.delete-catalog.catalog-key');
			    							   	 		dm_catalog.webMethod('delete-catalog');
			    							   	 	},
			    							   	 	mvc_enableControl:function(dm){
			    							   	 		var valid;
			    							   	 		if(vaild=dm.isPasswordValid()){
			    							   	 			if(!(valid=dm.isForumAdmin())){
			    							   	 				var user_key=dm.getValue('login.return.data.user-key');
			    							   	 				var node=this.getPaneById('catalog_pane').$V.catalog_node;
			    							   	 				valid=(user_key==node.getAttribute('CATALOG_USER_KEY'));
			    							   	 			}
			    							   	 		}
			    							   	 		this.style.display=((valid)?'':'none');
			           								}
			    							 }"
			    						>
			    						</span>
			    						<span title="new schema" id="new_schema" xlvobject="xlv.obj.dmProcess" style="margin-left:20px;display:none"
			    							 xlvprop="{dmName:'user',srcImg:'/xlive/images/forum/page_add.png',title:''}" 
			    							 xlvmethod="{
			    							   	 	process:function(options){
			    							  	 		var node=this.getPaneById('catalog_pane').$V.catalog_node;
			    							   	 		var dm_catalog=this.getDataModel('forum.catalog');
			    							   	 		dm_catalog.setValue(node.getAttribute('CATALOG_KEY'),'properties.new-schema.catalog-key');
			    							   	 		dm_catalog.setValue(node.getAttribute('CATALOG_ICON'),'properties.new-schema.schema-icon');
			    								 		var user=this.getDataModel('user');
			    								 		var user_key=user.getValue('login.return.data.user-key');
			    								 		dm_catalog.setValue(user_key,'properties.new-schema.user-key');
			    								 		dm_catalog.setValue('','properties.new-schema.schema-title');
			    								 		dm_catalog.setValue('','properties.new-schema.schema-text');
			    								 		dm_catalog.setValue(dm_catalog.getValue('properties.catalog-tree.forum-key'),'properties.new-schema.forum-key');
			    								 		this.getDesktop().showPane('/xlive/forum/newSchema.html',null,null,{invoker:this,align:'right'});
			    								 	},
			    							   	 	mvc_enableControl:function(dm){
			    							   	 		var valid;
			    							   	 		if(vaild=dm.isPasswordValid()){
			    							   	 			if(!(valid=dm.isForumAdmin())){
			    							   	 				var user_key=dm.getValue('login.return.data.user-key');
			    							   	 				var node=this.getPaneById('catalog_pane').$V.catalog_node;
			    							   	 				valid=(user_key==node.getAttribute('CATALOG_USER_KEY'));
			    							   	 			}
			    							   	 		}
			    							   	 		this.style.display=((valid)?'':'none');
			           								}
			    							 }"
			    						>
			    						</span>
			    						</nobr>
			    						<div id="catalog_time" style="white-space:nowrap;text-align:right;font-size:10px;color:gray"></div>
			    						<div id="user_name" xlvobject="xlv.obj.process" style="text-decoration:underline;font-size:10px;color:gray"
			    									xlvmethod="{
			    										process:function(options){
				    										var prop={caller:{user_key:this.$V.user_key}};
				    										this.getDesktop().showPane('/xlive/forum/user.html',prop,null,{invoker:this,align:'right'});
			    										}
			    									}"
			    								    >
			    						</div>
			    					</td>
			    					<td rowSpan="2">
			    						<div id="catalog_expand"></div>
			    					</td>
			    				</tr>
			    				<tr>
			    					<td width="100%"><span id="catalog_text"></span></td>
			    				</tr>
			    			</table>
			    			</div>
			    		</div>
			    		<ul>
			    			<li>
			    				<div id="schema_pane" xlvobject="xlv.obj.pane" 
			    				     xlvprop="{glow:{enable:true,hover:true,png:'_blueGlow.png'},border:{enable:true}}"
			    			 		 xlvmethod="{
			    			 		 	styleFor:function(root){
			    			 		 		root.style.background='#E0EDF3';
			    			 		 	},
			    			 			mvc_valueToView:function(node,indexes){
			    			 				this.$V.schema_node=node;
			    			 				if(xlv.util.getXmlNodeValue('SCHEMA_KEY',node)==''){
			    			 					this.getObjectById('forum_schema_table').style.display='none';
			    			 					return;
			    			 				}
			    			 				var value=xlv.util.getXmlNodeValue('SCHEMA_TITLE',node);
			    			 				var title=this.getObjectById('schema_title');
			    			 				title.setTitle(value);
			    			 				title.$V.schema_key=xlv.util.getXmlNodeValue('SCHEMA_KEY',node);
			    			 				value=xlv.util.getXmlNodeValue('SCHEMA_ICON',node);
			    			 				var img=this.getObjectById('schema_icon');
			    			 				img.src=value;
			    			 				value=xlv.util.getXmlNodeValue('SCHEMA_TEXT',node);
			    			 				var text=this.getObjectById('schema_text');
			    			 				text.innerHTML=value;
			    			 				var user_name=this.getObjectById('user_name');
			    			 				user_name.setTitle(xlv.util.getXmlNodeValue('USER_NAME',node));
			    			 				user_name.$V.user_key=xlv.util.getXmlNodeValue('USER_KEY',node);
			    			 				value=xlv.util.getXmlNodeValue('SCHEMA_TIME',node);
			    			 				value=new Date().parseDate(value).formatDate('yyyy/MM/dd HH:mm:ss');
			    			 				xlv.util.setElementValue(this.getObjectById('schema_time'),value);
			    			 		 	}
			    			 		 }"
			    					>
			    					<div style="padding:8px">
			    					<table id="forum_schema_table" border="0" cellpadding="0" cellspacing="0">
			    						<tr>
			    							<td rowSpan="2"><img width="32" height="32" id="schema_icon" style="margin-right:8px"></img></td>
			    							<td style="text-align:left;vertical-align:top">
			    								<div id="schema_title" xlvobject="xlv.obj.process" style="margin-bottom:8px;font-size:larger;"
			    									xlvmethod="{
			    										process:function(options){
			    											this.getBorderLayoutById('forum_main').setCenterPane('/xlive/forum/schema.html',{caller:{schema_key:this.$V.schema_key}},null,'bottom');
			    										}
			    									}"
			    								    >
			    								 </div>
			    							</td>
			    							<td rowSpan="2">
			    								 <nobr>
			    								 <span id="update_schema" title="update" xlvobject="xlv.obj.dmProcess" style="display:none"
			    								 		 xlvprop="{dmName:'user',srcImg:'/xlive/images/forum/page_edit.png',title:''}"
			    								    	 xlvmethod="{
			    								    	 	process:function(options){
			    								    	 		var schema_pane=this.getPaneById('schema_pane');
			    								    	 		var dm_catalog=this.getDataModel('forum.catalog');
			    								    	 		var schema_key=dm_catalog.getValue('SCHEMA_KEY', schema_pane.$V.schema_node);
			    								    	 		dm_catalog.setValue(schema_key,'properties.update-schema.schema-key');
			    								    	 		var schema_title=dm_catalog.getValue('SCHEMA_TITLE', schema_pane.$V.schema_node);
			    								    	 		dm_catalog.setValue(schema_title,'properties.update-schema.schema-title');
			    								    	 		var schema_text=dm_catalog.getValue('SCHEMA_TEXT', schema_pane.$V.schema_node);
			    								    	 		dm_catalog.setValue(schema_text,'properties.update-schema.schema-text');
			    								    	 		var schema_icon=dm_catalog.getValue('SCHEMA_ICON', schema_pane.$V.schema_node);
			    								    	 		dm_catalog.setValue(schema_icon,'properties.update-schema.schema-icon');
			    								    	 		this.getDesktop().showPane('/xlive/forum/updateSchema.html',null,null,{invoker:this,align:'right'});
			    								    	 	},
			    							   	 			mvc_enableControl:function(dm){
			    							   	 				var valid;
			    							   	 				if(vaild=dm.isPasswordValid()){
			    							   	 					if(!(valid=dm.isForumAdmin())){
			    							   	 						var user_key=dm.getValue('login.return.data.user-key');
			    							   	 						var node=this.getPaneById('schema_pane').$V.schema_node;
			    							   	 						valid=((user_key==xlv.util.getXmlNodeValue('CATALOG_USER_KEY',node))||
			    							   	 							  (user_key==xlv.util.getXmlNodeValue('USER_KEY',node)));
			    							   	 					}
			    							   	 				}
			    							   	 				this.style.display=((valid)?'':'none');
			           										}
			    								    	 }"
			    								 >
			    								 </span>
			    								 <span title="delete" xlvobject="xlv.obj.dmProcess" style="display:none"
			    								 		 xlvprop="{dmName:'user',srcImg:'/xlive/images/forum/page_delete.png',title:''}"
			    								    	 xlvmethod="{
			    								    	 	process:function(options){
			    								    	 		var schema_pane=this.getPaneById('schema_pane');
			    								    	 		var dm_catalog=this.getDataModel('forum.catalog');
			    								    	 		var schema_key=dm_catalog.getValue('SCHEMA_KEY', schema_pane.$V.schema_node);
			    								    	 		var schema_title=dm_catalog.getValue('SCHEMA_TITLE', schema_pane.$V.schema_node);
			    								    	 		if(!confirm('delete this schema : \n\n'+schema_title)) return;
			    								    	 		dm_catalog.setValue(schema_key,'properties.delete-schema.schema-key');
			    								    	 		dm_catalog.webMethod('delete-schema');
			    								    	 	},
			    							   	 			mvc_enableControl:function(dm){
			    							   	 				var valid;
			    							   	 				if(vaild=dm.isPasswordValid()){
			    							   	 					if(!(valid=dm.isForumAdmin())){
			    							   	 						var user_key=dm.getValue('login.return.data.user-key');
			    							   	 						var node=this.getPaneById('schema_pane').$V.schema_node;
			    							   	 						valid=((user_key==xlv.util.getXmlNodeValue('CATALOG_USER_KEY',node))||
			    							   	 							  (user_key==xlv.util.getXmlNodeValue('USER_KEY',node)));
			    							   	 					}
			    							   	 				}
			    							   	 				this.style.display=((valid)?'':'none');
			           										}
			    								    	 }"
			    								    >
			    								</span>
			    								</nobr>
			    								<div id="schema_time" style="white-space:nowrap;text-align:right;font-size:10px;color:gray"></div>
			    								<div id="user_name" xlvobject="xlv.obj.process" style="text-decoration:underline;font-size:10px;color:gray"
			    									xlvmethod="{
			    										process:function(options){
				    										var prop={caller:{user_key:this.$V.user_key}};
				    										this.getDesktop().showPane('/xlive/forum/user.html',prop,null,{invoker:this,align:'right'});
			    										}
			    									}">
			    								</div>
			    							</td>
			    						</tr>
			    						<tr>
			    							<td width="100%"><span id="schema_text"></span></td>
			    						</tr>
			    					</table>
			    					</div>
			    				</div>
			    			</li>
			    		</ul>
			    	</li>
			    </ul>
			</div>
		</div>
		<div id="xlvid_south">
			<!-- <div xlvobject="xlv.obj.tree" xlvprop="{dmName:'forum.catalog'}"></div>-->
		</div>
	</div>
</body>
</html>
